<script type="text/javascript">
$(function() {
	$('[name=cnpj]').mask('99.999.999/9999-99');
	$('[name=cep]').mask('99999-999');
})
</script>
<div class="content-box"><!-- Start Content Box -->
    
    <div class="content-box-header">
        
        <h3>Institui&ccedil;&otilde;es (<?php echo $total;?>)</h3>
        
  <ul class="content-box-tabs">
            <li><a href="#tab1" class="<?php echo $tab_lista;?>">Cadastradas</a></li> <!-- href must be unique and match the id of target div -->
            <li><a href="#tab2" class="<?php echo $tab_form;?>"><?php echo $editar_novo;?></a></li>
        </ul>
        
        <div class="clear"></div>
        
    </div> <!-- End .content-box-header -->
    
    <div class="content-box-content">
        
        <div class="tab-content <?php echo $tab_lista;?>" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
            
         	<div class="notification <?php echo $css_mensagens;?> png_bg" <?php echo $display_mensagens;?>>
                <a href="#" class="close"><img src="{base_url}/_img/admin/icons/cross_grey_small.png" title="Fechar esta notifica&ccedil;&atilde;o" alt="Fechar" /></a>
                <div>
                    <?php echo $mensagem;?>
                </div>
            </div>            
		    <form action="" method="post" id="formLista">
            <table>
                
                <thead>
                    <tr>
                       <th style="width:5%;"><input class="check-all" type="checkbox" /></th>
                       <th style="width:auto;">CNPJ</th>
                       <th style="width:auto;">Raz&atilde;o Social</th>
                       <th style="width:6%;">A&ccedil;&otilde;es</th>
                    </tr>
                    
                </thead>
             
                <tfoot>
                    <tr>
                        <td colspan="4">
                            <div class="bulk-actions align-left">
                            	
                                <select name="dropdownAcoes">
                                    <option value="">Com os selecionados...</option>
                                    <option value="<?php echo site_url("admin/" . $nome_secao ."/apagaVarios")?>">Excluir</option>
                                </select>
                                 
                                <a class="button" id="btAcao" style="cursor: pointer;">Aplicar</a>
                            </div>
                            
                            <div class="pagination"><?php paginator($pagina, $limite, $total_paginas, 'admin/' . $nome_secao .'/' . $lista_busca . '/')?></div>
                            <div class="clear"></div>
                        </td>
                    </tr>
                </tfoot>
             
                <tbody>
				<?php
                if (empty($rs)) {
                ?>
                    <tr>
                        <td colspan="4">Nenhum registro cadastrado.</td>                        
                    </tr>
				<?php
                }
                else {
                
                foreach ((array)$rs as $registro) {
                    $slug = $registro->slug;
                    $ativado = ($registro->ativo == 0) ? "des" : "";
                    $ativar = ($registro->ativo == 0) ? 1 : 0;
                ?>
                    <tr>
                        <td><input type="checkbox" name="ativo[]" value="<?php echo $slug;?>" /></td>

                        <td><?php echo $registro->cnpj;?></td>
                        <td><?php echo $registro->razao_social;?></td>
                        <td>
                            <!-- Icons -->
                             <a href="<?php echo site_url("admin/" . $nome_secao ."/edita/$slug");?>" title="Editar"><img src="{base_url}/_img/admin/icons/pencil.png" alt="Editar" /></a>
                             <a href="<?php echo site_url("admin/" . $nome_secao ."/trataApaga/$slug");?>" title="Excluir"><img src="{base_url}/_img/admin/icons/cross.png" alt="Excluir" /></a>
                        </td>                        
                    </tr>
				<?php
                    }
                }
                ?>
                </tbody>
            </table>

            </form>
           
        </div> <!-- End #tab1 -->
        
        <div class="tab-content <?php echo $tab_form;?>" id="tab2">

            <form id="moduloForm" action="<?php echo $action;?>" method="post">
                
                <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->

                   <p>
                        <label>CNPJ</label>
                        <input class="text-input small-input {validate: {required: true, cnpj: 'both'}}" type="text" name="cnpj" value="<?php echo $r->cnpj;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Nome Fantasia</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="nome_fantasia" value="<?php echo $r->nome_fantasia;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Raz&atilde;o Social</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="razao_social" value="<?php echo $r->razao_social;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Endere&ccedil;o</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="endereco" value="<?php echo $r->endereco;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>N&uacute;mero</label>
                        <input class="text-input {validate: {required: true, number: true}}" type="text" name="numero" value="<?php echo $r->numero;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Complemento</label>
                        <input class="text-input small-input {validate: {required: false}}" type="text" name="complemento" value="<?php echo $r->complemento;?>" />
                   </p>
                   <p>
                        <label>Bairro</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="bairro" value="<?php echo $r->bairro;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Cep</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="cep" value="<?php echo $r->cep;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Estado</label>
                        <?php echo uf_dropdown('uf', $r->uf, 'class="{validate: {required: true}}"');?>
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Cidade</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="cidade" value="<?php echo $r->cidade;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Telefone</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="telefone" value="<?php echo $r->telefone;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Nome do respons&aacute;vel pela assinatura no contrato</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="nome" value="<?php echo $r->nome;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Cargo do respons&aacute;vel pela assinatura no contrato</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="cargo_responsavel" value="<?php echo $r->cargo_responsavel;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>E-mail do respons&aacute;vel pela assinatura no contrato</label>
                        <input class="text-input small-input {validate: {required: true, email: true}}" type="text" name="email_responsavel" value="<?php echo $r->email_responsavel;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Nome do representante legal</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="nome_representante" value="<?php echo $r->nome_representante;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                        <label>Cargo do representante legal</label>
                        <input class="text-input small-input {validate: {required: true}}" type="text" name="cargo_representante" value="<?php echo $r->cargo_representante;?>" />
                        <br /><small>*Obrigat&oacute;rio</small>
                   </p>
                   <p>
                       <input class="button" type="submit" value="Salvar" />
                   </p>
                    
                </fieldset>
                
                <div class="clear"></div><!-- End .clear -->
                
            </form>
            
        </div> <!-- End #tab2 -->        
        
    </div> <!-- End .content-box-content -->
    
</div> <!-- End .content-box -->

<div class="clear"></div>